package com.itheima.mybatis.dao.Impl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.itheima.mybatis.dao.UserDao;
import com.itheima.mybatis.po.User;

public class UserDaoImpl implements UserDao {
		
	private SqlSessionFactory sqlSessionFactory;
	
	public UserDaoImpl (SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}
	
	@Override
	public User getUserById(int id) {
		SqlSession sqlSession = sqlSessionFactory.openSession();
		
		User user = sqlSession.selectOne("getUserById", id);
		sqlSession.close();
		return user;
	}

}
